<?php

namespace App\Console\Crons;

use App\Ad\Postback\PostbackService;
use App\Models\Log\LogAdPostback;

class AdPostbackRetryCron extends CronBase
{
    public function run($stime)
    {
        // 手动重试
        $end_time = $stime + 86400;
        $stime = $stime - 86400;
        $query = LogAdPostback::whereRaw("create_time>={$stime} AND create_time<{$end_time} AND status IN(60)");
        $query->chunk(10000, function ($list) {
            foreach ($list as $log) {
                PostbackService::getInstance()->postback($log);
            }
        });
    }
}
